package net.orcspace.myplace.personal.todo;

import net.orcspace.myplace.data.DataProvider;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * About TODO methods
 * @author Sun
 *
 */
@Controller
public class TodoController {

	@RequestMapping(value = "/todo/addItem",method = RequestMethod.POST)
	public String addTODO(@RequestParam("todoItem") String todoItem,Model model){
		DataProvider.p.addTodo(todoItem);
		return "redirect:/";
	}
	
	@RequestMapping(value = "/todo/delItem",method = RequestMethod.POST)
	public String delTODO(@RequestParam("todoId") long todoId,Model model){
		System.out.println("debug...."+todoId);
		DataProvider.p.delTodo(todoId);
		return "redirect:/";
	}
	
	@RequestMapping(value = "/todo/delAll",method = RequestMethod.GET)
	public String delALL(){
		DataProvider.p.delAll();
		return "redirect:/";
	}
}
